﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace MCMLXVII.BackEnd.Services.Common.Messages
{

    [Serializable()]
    public enum BackendFaulType
    {
        Technical = 0,
        Functional = 1,
        Security = 2,
        DataUpdateSequence = 3
    }
    [DataContract]
    public class BackendFault
    {
        private BackendFaulType _faultType;
        private int _faultCode;
        private string _faultDescription;
        private string _faultInfo;

        public BackendFault()
        {
                
        }

        public BackendFault(BackendFaulType faultType, int faultCode, string faultDescription, string faultInfo)
        {
            _faultCode = faultCode;
            _faultDescription = faultDescription;
            _faultInfo = faultInfo;
            _faultType = faultType;

        }

        public BackendFault(BackendFaulType faultType, string faultDescription, string faultInfo)
        {
            _faultCode = 0;
            _faultDescription = faultDescription;
            _faultInfo = faultInfo;
            _faultType = faultType;

        }

        public BackendFault(BackendFaulType faultType, string faultDescription)
        {
            _faultCode = -1;
            _faultDescription = faultDescription;
            _faultInfo = "";
            _faultType = faultType;

        }

        public BackendFault(BackendFaulType faultType)
        {
            _faultCode = 0;
            
            _faultInfo = "";
            _faultType = faultType;
            _faultDescription = "";
            switch (faultType)
            {
                case BackendFaulType.DataUpdateSequence: 
                    _faultDescription = "Bad Update Sequence";
                    break; 
            
            }

        }

        [DataMember()]
        public BackendFaulType faultType {get{ return _faultType;} set{ _faultType = value;}}
        [DataMember()]
        public int faultCode {get{ return _faultCode;} set{ _faultCode = value;}}
        [DataMember()]
        public string faultDescription {get{ return _faultDescription;} set{ _faultDescription = value;}}
        [DataMember()]
        public string faultInfo {get{ return _faultInfo;} set{ _faultInfo = value;}}

    }
}
